package hlhj.fhp.supreme.customview

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import hlhj.fhp.supreme.Contents
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.activitys.GroupBuyAty
import hlhj.fhp.supreme.activitys.PayAty
import kotlinx.android.synthetic.main.jiepan_dialog.*

/**
 * Created by Administrator on 2018\5\20 0020.
 */
class JiePanPayDialog(context:Context,private val money:String) :Dialog(context, R.style.CustomDialog) {

    private var payType=1;
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.jiepan_dialog)

        btStright.setOnClickListener {
            if (payType==2){
                payType=1
                btStright.setBackgroundResource(R.drawable.yellow_border)
                btStright.setTextColor(context.resources.getColor(R.color.them_yellow))
                btTuangou.setBackgroundResource(R.drawable.grey_border)
                btTuangou.setTextColor(context.resources.getColor(R.color.text_333))
            }else{

            }
        }
        btTuangou.setOnClickListener {
            if (payType==1){
                payType=2
                btTuangou.setBackgroundResource(R.drawable.yellow_border)
                btTuangou.setTextColor(context.resources.getColor(R.color.them_yellow))
                btStright.setBackgroundResource(R.drawable.grey_border)
                btStright.setTextColor(context.resources.getColor(R.color.text_333))
            }
        }

        btCancel.setOnClickListener {
            dismiss()
        }

        btCommit.setOnClickListener {
            if (payType==2){
                val intent = Intent(context, GroupBuyAty::class.java)
                context.startActivity(intent)
            }else{
                val intent = Intent(context, PayAty::class.java)
                intent.putExtra("et",5)
                intent.putExtra("pp",1)
                intent.putExtra("money",Contents.ONE)
                intent.putExtra("type","2")
                context.startActivity(intent)
            }
            dismiss()
        }

    }
}